/*
 * @Date: 2023-01-08 13:47:28
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-04-05 12:03:47
 * @FilePath: \A19\frontend\src\getClient.ts
 */
import { HttpClient, WsClient } from "tsrpc-browser";
import { serviceProto, ServiceType } from "./shared/protocols/serviceProto";
import { conf } from "@/utils/conf";
import { encryWs } from "./flowNodes/encry";
export function getWsClient(): WsClient<ServiceType> {
  const wscli = new WsClient(serviceProto, {
    server: conf.wsserver,
    // Remove this to use binary mode (remove from the server too)
    json: false,
    logger: console,
    logLevel: "warn",
    heartbeat: {
      interval: 8000,
      timeout: 5000,
    },
  });

  encryWs(wscli);

  return wscli;
}
export function getClient(): HttpClient<ServiceType> {
  return new HttpClient(serviceProto, {
    server: conf.serviceServer,
    json: false,
    logger: console,
    logLevel: "warn",
  });
}
